﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using AbcCorp.BLO;
using AbcCorp.DTO;

namespace AbcCorp.AccountService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class AccountService : IAccountService
    {
        public Account SignIn(string username, string password)
        {
            var accountBlo = new AccountBlo();
            var account = new Account();
            var accountDto = accountBlo.SignIn(username, password);
            if (accountDto == null) return null;
            CopyObject<AccountDto, Account>.CopyProperties(accountDto, account);
            return account;
        }

        public bool SignUp(Account newAccount)
        {
            var accountBlo = new AccountBlo();
            var accountDto = new AccountDto();
            CopyObject<Account, AccountDto>.CopyProperties(newAccount, accountDto);
            return accountBlo.SignUp(accountDto);
        }

        public string GetPassword(string username, string email)
        {
            var accountBlo = new AccountBlo();
            return accountBlo.GetPassword(username, email);
        }

        public bool UpdatePassword(string username, string email, string password, string newpassword)
        {
            var accountBlo = new AccountBlo();
            return accountBlo.UpdatePassword(username, email, password, newpassword);
        }

        public bool UpdatePasswordByCode(string code, string newPassword)
        {
            var accountBlo = new AccountBlo();
            return accountBlo.UpdatePasswordByCode(code, newPassword);
        }

        public int GetAccountId(string username)
        {
            var accountBlo = new AccountBlo();
            return accountBlo.GetAccountId(username);
        }
    }
}
